package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.CrowdDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Crowd and its DTO CrowdDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, })
public interface CrowdMapper extends EntityMapper <CrowdDTO, Crowd> {

    @Mapping(source = "product.id", target = "productId")
    CrowdDTO toDto(Crowd crowd); 

    @Mapping(source = "productId", target = "product")
    Crowd toEntity(CrowdDTO crowdDTO); 
    default Crowd fromId(Long id) {
        if (id == null) {
            return null;
        }
        Crowd crowd = new Crowd();
        crowd.setId(id);
        return crowd;
    }
}
